package org.colafries.admin.controller;

import org.colafries.admin.entity.vo.CustomTableReqVO;
import org.colafries.admin.entity.domain.CustomTable;
import org.colafries.admin.service.ICustomTableService;
import org.colafries.admin.wrapper.Response;
import org.colafries.admin.wrapper.ResponseWrapper;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author colafries
 * @version v1.0
 * @ClassName CustomTableController
 * @Description
 * @date Created in 2024/4/8
 **/
@RestController
@RequestMapping("/customTable")
public class CustomTableController {

    @Resource
    ICustomTableService iCustomTableService;

    /**
     * 获取列表
     *
     * @param customTableReqVO
     * @author colafries
     * @Date 2024/4/8
     */
    @PostMapping("/getAll")
    public Response getAll(@RequestBody CustomTableReqVO customTableReqVO) {
        List<CustomTable> customTables = iCustomTableService.getAll(customTableReqVO);
        return ResponseWrapper.ok(customTables);
    }

    /**
     * 根据数据模型id获取自定义表
     *
     * @param customTableReqVO
     * @author colafries
     * @Date 2024/4/22
     */
    @PostMapping("/getByDataModelId")
    public Response getByDataModelId(@RequestBody CustomTableReqVO customTableReqVO) {
        List<CustomTable> customTables = iCustomTableService.lambdaQuery()
                .eq(CustomTable::getDataModelId, customTableReqVO.getDataModelId())
                .list();
        return ResponseWrapper.ok(customTables);
    }

    /**
     * 新增自定义表
     *
     * @param customTableReqVO
     * @return org.colafries.admin.wrapper.Response
     * @Author anning
     * @Date 2024/6/28
     */
    @PostMapping("/add")
    public Response add(@RequestBody CustomTableReqVO customTableReqVO) {
        return ResponseWrapper.ok();
    }

    /**
     * 修改自定义表
     *
     * @param customTableReqVO
     * @return org.colafries.admin.wrapper.Response
     * @Author anning
     * @Date 2024/6/28
     */
    @PostMapping("/update")
    public Response update(@RequestBody CustomTableReqVO customTableReqVO) {
        return ResponseWrapper.ok();
    }

    /**
     * 删除自定义表
     *
     * @param customTableReqVO
     * @return org.colafries.admin.wrapper.Response
     * @Author anning
     * @Date 2024/6/28
     */
    @PostMapping("/delete")
    public Response delete(@RequestBody CustomTableReqVO customTableReqVO) {
        return ResponseWrapper.ok();
    }

}
